package com.xb.service.imp;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xb.entity.LoginInfo;
import com.xb.mapper.LoginInfoMapper;
import com.xb.service.ILoginInfoService;
import com.xb.util.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Service业务层处理
 */
@Service
public class LoginInfoServiceImp implements ILoginInfoService {
    @Resource
    private LoginInfoMapper loginInfoMapper;


    @Override
    public Result selectLoginInfoList(LoginInfo loginInfo, Integer page, Integer limit) {
        Result result = new Result();
        PageHelper.startPage(page, limit);
        List<LoginInfo> list = loginInfoMapper.selectLoginInfoList(loginInfo);
        PageInfo<LoginInfo> loginInfoPageInfo = new PageInfo<>(list);
        if (loginInfoPageInfo.getList() != null) {
            result.setStatus(Result.RESPONSE_SUCCESS);
            result.setData(loginInfoPageInfo.getList());
            result.setTotal(loginInfoPageInfo.getTotal());
            result.setMessage("查询成功");
        }
        return result;
    }


    /**
     * 新增
     *
     * @param loginInfo
     * @return 结果
     */
    @Override
    public int insertLoginInfo(LoginInfo loginInfo) {
        return loginInfoMapper.insertLoginInfo(loginInfo);
    }

}
